<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class main extends CI_Controller {

	function __construct()
	{
		parent::__construct();
	    $this->load->model("mod");
		$this->load->model("version");
		$this->load->model("complete");
	    $this->load->model("category");
	    $this->load->model("company");
	    $this->load->model("receive");
        $this->load->model("receive_record");
	    $this->load->model("receive_update");
	    $this->load->model("send");
	    $this->load->model("send_record");
	    $this->load->model("send_update");
	    $this->load->model("inventory");
		$this->load->model("admin");
		
	}

	function inventory(){
	    $receive = $this->receive->select_s();

	    for($i=0;$i<count($receive);$i++){
	    	$s = $this->send->sel(array('mod_id'=>$receive[$i]->mod_id,'category_id'=>$receive[$i]->category_id,'version_id'=>$receive[$i]->version_id));
           if(count($s)>0){
	    	$d = array(
	                           'mod_id'=>$receive[$i]->mod_id,
	                           'category_id'=>$receive[$i]->category_id,
	                           'version_id'=>$receive[$i]->version_id,
	                           'count'=>$receive[$i]->count-$s[0]->count
	               );
           }else{
               $d = array(
	                           'mod_id'=>$receive[$i]->mod_id,
	                           'category_id'=>$receive[$i]->category_id,
	                           'version_id'=>$receive[$i]->version_id,
	                           'count'=>$receive[$i]->count
	               );
           }       
	               $this->inventory->insert($d);
	       }
	    }

	
	
	function get_category_detail(){
		$mod = $this->mod->select('');
	    $mods = array();
		foreach($mod as $k=>$val){
		    $mods[$val->mod_id] = $val->name;
		}
		$category = $this->category->select('');
		$categorys = array();
	    foreach($category as $k=>$val){
		    $categorys[$val->category_id] = array('name'=>$val->name,'level'=>$val->level);
		}
		
		$version = $this->version->select('');
	    $versions = array();
	    foreach($version as $k=>$val){
		    $versions[$val->version_id] = $val->name;
		}
	    $company = $this->company->select('');
	    $companys = array();
		foreach($company as $k=>$val){
		    $companys[$val->company_id] = $val->name;
		}
		$levels = array('机密','秘密','内部');
	    $category_id = $_POST['category_id'];
//取出当前库存
        $ar = array('inventory.category_id'=>$category_id);
        $inventorys = $this->inventory->select_join($ar) ;
        $data = array();
        if(count($inventorys)!=0){
	        foreach ($inventorys as $k=>$val) {

	        	$data_mod = $mods[$val->mod_id];
	        	$data_category = $categorys[$val->category_id]['name'];
	        	$data_version = $versions[$val->version_id];	    
			    $co = $this->inventory->getcount($val->category_id,$val->version_id);
			    $data_total_count = $co[0]->count;
			    $data_level = $levels[$categorys[$val->category_id]['level']];
			//查找接收日期
			    $receive = $this->receive_record->getreceive_array(array('category_id'=>$val->category_id,'version_id'=>$val->version_id));   
			   // error_log(print_r($receive,true),3,'d:/val.txt');
			    $data_receive_date = date('Y.m.d',$receive[0]->createtime);
		    //根据category_id 查找出所有的version,并倒序排	    
		        $cates = $this->version->getversion_bycategory_id($val->category_id);
		        $cates_count = count($cates);
		        $data_orignal_version = $cates[$cates_count-1]->name;
		        $ver = $this->version->select(array('version_id'=>$val->version_id));
		        $data_current_version = $ver[0]->name;
		        $data_valid_version = $cates[0]->name;
		        $data_company = "库存";
		        $data_sendtime = "-";
		        $data_updatetime="";
		        $data_updatedes="";
		        $data[]=array('id'=>$val->inventory_id,'mod'=>$data_mod,'category'=>$data_category,'version'=>$data_version,'total_count'=>$data_total_count,'level'=>$data_level,
		                      'receive_date'=>$data_receive_date,'orignal_version'=>$data_orignal_version,'current_version'=>$data_current_version,
		                      'valid_version'=>$data_valid_version,'company'=>$data_company,'sendtime'=>$data_sendtime,'updatetime'=>$data_updatetime,
		                      'updatedes'=>$data_updatedes);
	        }
        }
//取出已发布	    
        $arr = array('send.category_id'=>$category_id);
	    $sends = $this->send->select_join($arr);

	    if(count($sends)!=0){
	        foreach ($sends as $k=>$val) {

	        	$data_mod = $mods[$val->mod_id];
	        	$data_category = $categorys[$val->category_id]['name'];
	        	$data_version = $versions[$val->version_id];    
			    $data_total_count = $val->count;
			    $data_level = $levels[$categorys[$val->category_id]['level']];
			//查找接收日期
			    $receive = $this->receive_record->getreceive_array(array('category_id'=>$val->category_id,'version_id'=>$val->version_id));   
			   /// error_log(print_r($receive,true),3,'d:/val.txt');exit; 
			    $data_receive_date = date('Y.m.d',$receive[0]->createtime);
		    //根据category_id 查找出所有的version,并倒序排	    
		        $cates = $this->version->getversion_bycategory_id($val->category_id);
		        $cates_count = count($cates);
		        $data_orignal_version = $cates[$cates_count-1]->name;
		        $ver = $this->version->select(array('version_id'=>$val->version_id));
		        $data_current_version = $ver[0]->name;
		        $data_valid_version = $cates[0]->name;
		        $data_company = $companys[$val->company_id];
		        $data_sendtime = date('Y.m.d',$val->createtime);
		        $data_updatetime="";
		        $data_updatedes="";
		        $data[]=array('id'=>$val->send_id,'mod'=>$data_mod,'category'=>$data_category,'version'=>$data_version,'total_count'=>$data_total_count,'level'=>$data_level,
		                      'receive_date'=>$data_receive_date,'orignal_version'=>$data_orignal_version,'current_version'=>$data_current_version,
		                      'valid_version'=>$data_valid_version,'company'=>$data_company,'sendtime'=>$data_sendtime,'updatetime'=>$data_updatetime,
		                      'updatedes'=>$data_updatedes);
	        }
        }
//	    error_log(print_r($data,true),3,'d:/val.txt');exit; 
	    echo json_encode($data);
	}
	
	
	function login(){
	   if($_POST){
	   	   $array=array('username'=>$_POST['username'],'password'=>$_POST['password']);
		   $result=$this->admin->login($array);
		   $count = count($result);
		 
		   if($count>=1){
                $this->session->set_userdata('user',$result);
				header("Location:".site_url()."main/index");
		   }
		   else{
				header("Location:".site_url()."main/login");
		   }
	   }else{
	       $this->load->view('login');
	   }	
	}
	
	
	function logout(){
	    $user = $this->session->userdata('user');
        if($user==""){ 
			//直接跳转到登录页面
			redirect('main/login');exit;
		}else{
		   $this->session->sess_destroy(); 
		   redirect('main/index');exit;
		}
	
	}
	
	function index(){
		$this->top();

//接搜session
        if($_POST){
          $this->session->set_userdata('mod_id',$_POST['mod']);
          $this->session->set_userdata('category_id',$_POST['category']);
          $this->session->set_userdata('version_id',$_POST['version']);
          $this->session->set_userdata('company_id',$_POST['company']);
          $this->session->set_userdata('level',$_POST['level']);
          $this->session->set_userdata('update',$_POST['update']);
          $this->session->set_userdata('first_time',$_POST['first_time']);
          $this->session->set_userdata('second_time',$_POST['second_time']);
          $this->session->set_userdata('third_time',$_POST['third_time']);
        }


        $da = "1=1 ";
        $mod_id=$this->session->userdata('mod_id');
        $category_id=$this->session->userdata('category_id');
        $version_id=$this->session->userdata('version_id');
        $company_id=$this->session->userdata('company_id');
        $level=$this->session->userdata('level');
        $update=$this->session->userdata('update');
        $first_time=$this->session->userdata('first_time');
        $second_time=$this->session->userdata('second_time');
        $third_time=$this->session->userdata('third_time');
        $data['select_mod_id'] = $mod_id;
        $data['select_category_id'] = $category_id;
        $data['select_version_id'] = $version_id;
        $data['select_company_id'] = $company_id;
        $data['select_level'] = $level;
        $data['select_update'] = $update;
        $data['first_time'] = $first_time;
        $data['second_time'] = $second_time;
        $data['third_time'] = $third_time;
        
        
        if($mod_id!=""){
        	
        	$da.=" and mod_id=".$mod_id;
        }
	    if($category_id!=""){
		   	$da.=" and category_id=".$category_id;
        }
	    if($version_id!=""){
	    	$v = $this->version->getversion_array(array('version_id'=>$version_id));
        	$da.=" and category_id=".$v[0]->category_id;
        }else{
            $version_id="";
        }
	    if($company_id!=""){
    //查询发放记录，通过公司id获取category_id
          $arr = array('company_id'=>$company_id);
          $companys = $this->send->select_by_array($arr);
          $com_count = count($companys);
          $str='';
          if($com_count>0){ 
	          for($i=0;$i<$com_count;$i++){
	             $str.="'".$companys[$i]->category_id."'";
	             if($i!=$com_count-1){
	               $str.=",";
	             }
	          }
          }
          if($str!=""){
             $da.=" and category_id in (".$str.")";
          }
        }
        
	    if($level!=""){
        	$da.=" and level=".$level;
        }

	    if($first_time!=""){
        	$receives = $this->receive->select_by_array(array('createtime'=>strtotime(str_replace('.', '-', $first_time))));
        	$receive_count = count($receives);
	          $str_receive='';
	          if($receive_count>0){ 
		          for($i=0;$i<$receive_count;$i++){
		             $str_receive.="'".$receives[$i]->category_id."'";
		             if($i!=$receive_count-1){
		               $str_receive.=",";
		             }
		          }
	          }
	          if( $str_receive!="" ){
	              $da.=" and category_id in (".$str_receive.")";
	          }else{
	              $da.=" and category_id in ('xxxx')";
	          }
        }
	    if($second_time!=""){
        	$sends = $this->send->select_by_array(array('createtime'=>strtotime(str_replace('.', '-', $second_time))));
        	$send_count = count($sends);
	          $str_send='';
	          if($send_count>0){ 
		          for($i=0;$i<$send_count;$i++){
		             $str_send.="'".$sends[$i]->category_id."'";
		             if($i!=$send_count-1){
		               $str_send.=",";
		             }
		          }
	          }
	          if($str_send!=""){
	              $da.=" and category_id in (".$str_send.")";
	          }else{
	              $da.=" and category_id in ('xxxx')";
	          }
        }
	    if($third_time!=""){
          //分别去查找两个更新表
          $send_update = $this->send_update->select_by_array(array('createtime'=>strtotime(str_replace('.', '-', $third_time))));
        	$send_count_up = count($send_update);
	          $str_send_up='';
	          if($send_count_up>0){ 
		          for($i=0;$i<$send_count_up;$i++){
		             $str_send_up.="'".$send_update[$i]->category_id."'";
		             if($i!=$send_count_up-1){
		               $str_send_up.=",";
		             }
		          }
	          }
	       if($str_send_up!=""){   
	           $da.=" and category_id in (".$str_send_up.")";
	       }

	    $receive_update = $this->receive_update->select_by_array(array('createtime'=>$third_time));
        	$receive_count_up = count($receive_update);
	          $str_receive_up='';
	          if($receive_count_up>0){ 
		          for($i=0;$i<$receive_count_up;$i++){
		             $str_receive_up.="'".$receive_update[$i]->category_id."'";
		             if($i!=$receive_count_up-1){
		               $str_receive_up.=",";
		             }
		          }
	          }
	       if($str_receive_up!=""){   
	           $da.=" and category_id in (".$str_receive_up.")";
	       }else{
	              $da.=" and category_id in ('xxxx')";
	          }
        }
        
 //取得所有类别的最新版本和类别号
     $sr = $this->version->get_last_verison(); 
     $ggg = $this->inventory->select('');   
	   $invalid_category = 0;
	   $invalid_files = 0;
        if($update!=""){                       	
           if($update==0||$update==1){
              $inventory = $this->inventory->select('');
              $inventory_record = count($inventory);
	          $inventory_record_valid='';
	          $inventory_record_invalid='';

	          if($inventory_record>0){ 
		          	 for($j=0;$j<count($sr);$j++){
//先根据种类号，去查询是不是存在，然后再去拿最高版本去查询
                         $cat = $this->inventory->select_by_array(array('category_id'=>$sr[$j]['category_id']));	
                         $cat_count = count($cat);
                         if($cat_count>0){
                         
                           $re = $this->inventory->getlast_foo($sr[$j]['version_id'],$sr[$j]['category_id']);

                           if(count($re)==0){
                           	 $inventory_record_valid.="'".$sr[$j]['category_id']."',";
                           }else{
                           	 $inventory_record_invalid.="'".$sr[$j]['category_id']."',";
                           	 $invalid_category++;
                           	 $ss = $this->inventory->select_count($sr[$j]['category_id']);
                           	 $invalid_files+=$ss[0]->count;
                           }
                         }         	 	
		          	 }
	          }  
		       $inventory_record_lid="";   
	           if($inventory_record_valid!=""&&$update==0){   
	           	   $l = strlen($inventory_record_valid);
	           	   $inventory_record_lid = substr($inventory_record_valid,0,$l-1);
		       }   
		       if($inventory_record_invalid!=""&&$update==1){  
		           $l = strlen($inventory_record_invalid); 
		           $inventory_record_lid = substr($inventory_record_invalid,0,$l-1);	           
		       }  
		       if($inventory_record_lid!=""){
		          $da.=" and category_id in (".$inventory_record_lid.")"; 
		       }else{
		          $da.=" and category_id in ('xxx')"; 
		       }
           }else if($update==2||$update==3){
  //首先从send_record表里取出所有的category_id,然后去version表里取出所有的version_id 
              $send = $this->send->select('');
              $send_record = count($send);
	          $send_record_valid='';
	          $send_record_invalid='';
	          $as=array();
	          if($send_record>0){ 
		          	 for($j=0;$j<count($sr);$j++){
		          	 //先根据种类号，去查询是不是存在，然后再去拿最高版本去查询
                         $cat = $this->send->select_by_array(array('category_id'=>$sr[$j]['category_id']));	
                         $cat_count = count($cat);
                         if($cat_count>0){
                           $re = $this->send->getlast_foo($sr[$j]['version_id'],$sr[$j]['category_id']);
                           $as[] = array('category_id'=>$sr[$j]['category_id'],'version_id'=>$sr[$j]['version_id']);
                           if(count($re)==0){
                           	 $send_record_valid.="'".$sr[$j]['category_id']."',";
                           }else{
                           	 $send_record_invalid.="'".$sr[$j]['category_id']."',";
                           	 $invalid_category++;
                           	 $ss = $this->send->select_count($sr[$j]['category_id']);
                           	 $invalid_files+=$ss[0]->count;
                           }                          
                         }
		          	 }
	          }    
		       $send_record_lid="";   
	           if($send_record_valid!=""&&$update==2){   
	           	   $l = strlen($send_record_valid);
	           	   $send_record_lid = substr($send_record_valid,0,$l-1);
		       }   
		       if($send_record_invalid!=""&&$update==3){  
		           $l = strlen($send_record_invalid); 
		           $send_record_lid = substr($send_record_invalid,0,$l-1);	           
		       }  
		       if($send_record_lid!=""){
		          $da.=" and category_id in (".$send_record_lid.")";       
		       }else{
		          $da.=" and category_id in ('xxx')"; 
		       }    
           }        
        }
		$data['level_data'] =array('机密','秘密','内部');
		$data['mod']=$this->mod->select('');
		$data['company']=$this->company->select('');
		$data['cate']=$this->category->select('');
		$data['version']=$this->version->select('');
		
		$total = $this->category->main_select($da);
		$to_category = array();
		foreach($total as $k=>$val){
		  $to_category[]=$val->category_id;
		}
//为了下面的循环，防止category_id重复		
		$check_array=array();
		$check_arrays=array();
		$invalid_file=0;
	    for($j=0;$j<count($sr);$j++){
	 //先根据种类号，去查询是不是存在，然后再去拿最高版本去查询
                         $cat = $this->send->select_by_array(array('category_id'=>$sr[$j]['category_id']));	
                         $cat_count = count($cat);
                         if($cat_count>0){
                           $re = $this->send->getlast_foo($sr[$j]['version_id'],$sr[$j]['category_id']);
                           if((count($re)!=0)&&(in_array($sr[$j]['category_id'],$to_category))&&(!in_array($sr[$j]['category_id'],$check_array))){                           	
                           	 $check_array[]=$sr[$j]['category_id'];
                           	 $ss = $this->send->select_where($sr[$j]['category_id'],$sr[$j]['version_id']);
                           	 $invalid_file+=$ss;
                           }
                         }
                         
                         $cat = $this->inventory->select_by_array(array('category_id'=>$sr[$j]['category_id']));	
                         $cat_count = count($cat);
                         if($cat_count>0){
                           $re = $this->inventory->getlast_foo($sr[$j]['version_id'],$sr[$j]['category_id']);
                           if((count($re)!=0)&&(in_array($sr[$j]['category_id'],$to_category))&&(!in_array($sr[$j]['category_id'],$check_array))){
                           	 $check_array[]=$sr[$j]['category_id'];
                           	 $ss = $this->inventory->select_where($sr[$j]['category_id'],$sr[$j]['version_id']);
                           	 $invalid_file+=$ss;
                           }
              }                           
	    }
	    $config['base_url'] =  site_url('main/index/');
	    
		$config['total_rows'] = count($total);
		$config['per_page'] = 10; 
		$config['num_links'] =10; 
		$config['first_link'] = '首页';
		$config['last_link'] = '尾页';
		$config['next_link'] = '下一页';
        $config['prev_link'] = '上一页';
        $config['full_tag_open'] = '<div>';
        $config['full_tag_close'] = '</div>';  
		$this->pagination->initialize($config); 
		$data['pages'] = ceil(count($total)/10);
		$data['page'] = $this->pagination->create_links();
		$page = $this->uri->segment(3);
		
		if($page==""){
		  $page=0;
		}
//搜索条件			
		$category = $this->category->main_select($da,$config['per_page'],$page);
//取得查询所得型号
        $category_mod = $this->category->main_select_count($da,'mod_id');
        $mod_count = count($category_mod);
        if($mod_count==1){

           $comp = $this->complete->select_array(array('mod_id'=>$category_mod[0]->mod_id));
//判断是否有全套资料，先去种类表查找所有的种类，然后根据种类去库存查找数量 
           $total_category = $this->category->getcategory_bymod_id($category_mod[0]->mod_id);
           $count_array_total = array();
           foreach ($total_category as $k=>$val){
               $cc = $this->inventory->select_count($val->category_id);
               if($cc[0]->count!=''){ $cou = $cc[0]->count;}else{$cou=0;}     
               $count_array_total[] = $cou;        
               $count_array_total2[] = array($val->category_id=>$cou);  
           }
       $ss="";  
           foreach( $comp as $k=>$val ){
                $temp = explode(',',$val->category_ids);
                foreach( $temp as $kk=>$v){
	                $cc = $this->inventory->getcount($v);
	                
	                if($cc[0]->count!=''){ $co = $cc[0]->count;}else{$co=0;}     
	                $com_temp[] = $co;
                }
                if(min($com_temp)!=0){
                   $ss .= min($com_temp)."套".$val->name."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                   unset($com_temp);
                }
           } 

        $data['temp_com'] = $ss;
        $data['total_complete'] = min($count_array_total);   
        }
//取得查询所得技术资料种类
        $category_cate = $this->category->main_select_count($da,'category_id');
        $cate_count = count($category_cate);
        $categorys = $this->category->main_select($da);
//取得查询技术资料份数
        $total_count = 0;       
        for($i=0;$i<count($categorys);$i++){
//查询数量,包括已发放的，和库存的        	
        	$inven = $this->inventory->getcount($categorys[$i]->category_id,$version_id); 
        	$co = $this->send_record->getcount($categorys[$i]->category_id,$version_id);
        	$total_count+=$inven[0]->count;
		    $total_count+=$co[0]->count;
        }      
        
		for($i=0;$i<count($category);$i++){

		     $count = $this->receive->getcount($category[$i]->category_id,$version_id);
		     $inven = $this->inventory->getcount($category[$i]->category_id,$version_id); 
		     $category[$i]->left_count = $inven[0]->count;
		     $co = $this->send_record->getcount($category[$i]->category_id,$version_id);
		     $category[$i]->total_count = $co[0]->count+ $inven[0]->count;
//取得有效版次    
		     $ver = $this->version->getvalidversion($category[$i]->category_id);
		     $category[$i]->valid_version = $ver[0]->name;
//去库存里查询category_id,去查询version_id 不是有效版次的数量，如果数量大于零，则要更新，否则不需要更新
             	     
//查询已更新
		     $last = $this->inventory->getlast($ver[0]->version_id,$category[$i]->category_id);
		     $send_last = $this->send->getlast($ver[0]->version_id,$category[$i]->category_id);
		     
		     $last_fo = $this->inventory->getlast_fo($ver[0]->version_id,$category[$i]->category_id);
             $send_last_fo = $this->send_record->getlast_fo($ver[0]->version_id,$category[$i]->category_id);   
             
//已更新份数此处可能存在问题                                      
		    // $category[$i]->valid_count = $last[0]->count+$send_last[0]->count;
		    
		     $category[$i]->valid_count = $category[$i]->total_count-$last_fo[0]->count-$send_last_fo[0]->count;
		     
		     $category[$i]->invalid_count = $last_fo[0]->count+$send_last_fo[0]->count;
		     if($category[$i]->invalid_count>0){
                  $category[$i]->need_update=1;
             }else{
                  $category[$i]->need_update=0;
             }
//发放单位
		     $com = $this->send->getcom($category[$i]->category_id);    
		     $str = "发放单位：";
		     foreach($com as $k=>$val){
		     	if($k<2){
			        $company = $this->company->select($val->company_id); 
			        $str.=$company[0]->name.";&nbsp;&nbsp;&nbsp;";
		     	} 
		     }
		     if(count($com)>=3){
		       $str.="...";
		     }
		     $str.="共".count($com)."个单位";
		     if(count($com)==0){
		       $str="";
		     }
		     $category[$i]->company = $str;
		}
		//error_log(print_r($check_array,true),3,'d:/log.txt');
        $data['invalid_category'] = count($check_array);
        $data['invalid_files']  = $invalid_file;
		$data['categorycount'] = $cate_count;
		$data['modcount'] = $mod_count;
		$data['totalcount'] = $total_count;
		$data['category'] = $category; 
		$this->load->view('main',$data);
		
	}
	
	function top(){
		$user = $this->session->userdata('user');

		if($user!=""){
			$data['user'] = $user;
		}else{ 
			//直接跳转到登录页面
			redirect('main/login');exit;
		}
	    $data['module']=$this->uri->segment(1);
	    $data['template']=$this->uri->segment(2);
	    $data['level_data'] = array('机密','秘密','内部');
	    $data['update_data'] = array('库存已更新','库存未更新','发放已更新','发放未更新');
	    $this->load->view('top',$data);
	}
	
	
	function getcategory(){
		  $mod_id = $_POST['mod_id'];
	      $result = $this->category->getcategory_bymod_id($mod_id);
	      $count = count($result);
	      $str="";
	      if($count!=0){
	         $str.="<a href='javascript:void(0)'  onclick='category_click(this)' alt=''>全部</a>&nbsp;&nbsp;";
	         for($i=0;$i<$count;$i++){
	           $str.="<a href='javascript:void(0)' onclick='category_click(this)' alt='".$result[$i]->category_id."'>".$result[$i]->name."</a>&nbsp;&nbsp;";
	         }
	         echo $str;
	      }else{
	        echo "<a href='javascript:void(0)'  onclick='category_click(this)' alt=''>全部</a>&nbsp;&nbsp;";
	      }
	}
	
	function getversion(){
	      $category_id = $_POST['category_id'];
	      $result = $this->version->getversion_bycategory_id($category_id);
	      $count = count($result);
	      $str="";
	      if($count!=0){
	         $str.="<a href='javascript:void(0)'  onclick='version_click(this)' alt=''>全部</a>&nbsp;&nbsp;";
	         for($i=0;$i<$count;$i++){
	           $str.="<a href='javascript:void(0)' onclick='version_click(this)' alt='".$result[$i]->version_id."'>".$result[$i]->name."</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
	         }
	         echo $str;
	      }else{
	        echo "<a href='javascript:void(0)'  onclick='version_click(this)' alt=''>全部</a>&nbsp;&nbsp;";
	      }
	  
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */